package edu.hrbeu.crc.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import edu.hrbeu.crc.pojo.entity.Category;
import edu.hrbeu.crc.pojo.result.Result;
import edu.hrbeu.crc.pojo.vo.CategoryVO;
import edu.hrbeu.crc.service.CategoryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/category")
public class CategoryController {


    private final CategoryService categoryService;

    /**
     * 显示分类信息
     * @param type
     * @return
     */
    @GetMapping("/list")
    public Result<List<CategoryVO>> list(@RequestParam Integer type) {
        log.info("查询分类（0支出1收入）：{}",type);

        List<CategoryVO> list = categoryService.display(type);
        return Result.success(list);
    }


}
